package com.etc.util;



import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

import org.apache.tomcat.util.codec.binary.Base64;


/**
 * 前段解码工具包
 * @author nxlnian
 *
 */
public class AesLoUtil {
	private static final String KEY = "0102030405060708";
	/** 
	 * 解密 （用于解密传输数据）
	 * @param encryptStr
	 * @param decryptKey
	 * @return
	 */
	
	 public static String Decrypt(String content) throws Exception{    
	        byte[] raw = KEY.getBytes("ASCII");    
	        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");    
	        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); 
	        IvParameterSpec iv = new IvParameterSpec(KEY.getBytes());
	        cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);    
	        byte[] encrypted1 = Base64.decodeBase64(content);//先用bAES64解密   
	        byte[] original = cipher.doFinal(encrypted1);    
	        String originalString = new String(original,"UTF-8");    
	        return originalString;    
	    } 
	
}
